import 'dart:io';

import 'package:cbec_app/app.dart';
import 'package:cbec_app/components/http/api.dart';
import 'package:cbec_app/components/http/base_network.dart';
import 'package:cbec_app/entity/base_entity.dart';
import 'package:cbec_app/entity/goods_center/clasify_item_entity.dart';
import 'package:cbec_app/entity/lottery/lotter_result_bean.dart';
import 'package:cbec_app/entity/lottery/lottery_bean.dart';
import 'package:cbec_app/entity/signIn/sign_in_recored_bean.dart';
import 'package:cbec_app/entity/user_center/address_list_entity.dart';
import 'package:cbec_app/entity/user_center/bank_card_item_entity.dart';
import 'package:cbec_app/entity/user_center/coupon_list_entity.dart';
import 'package:cbec_app/entity/user_center/khh_list_entity.dart';
import 'package:cbec_app/entity/user_center/provice_city_area_entity.dart';
import 'package:cbec_app/entity/user_center/user_login_entity.dart';
import 'package:cbec_app/pages/my/view/add_prepayment_card.dart';
import 'package:cbec_app/components/app_conifg.dart';
import 'package:cbec_app/utils/AppData.dart';
import 'package:cbec_app/utils/GlobalData.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:cbec_app/utils/cache_mgr.dart';
import 'package:cbec_app/utils/logger.dart';
import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';

import '../../entity/goods_center/comment_file_entity.dart';
import '../../entity/lottery/lottery_list_bean.dart';
import '../../entity/signIn/sign_in_prize_bean.dart';

///网络请求 直接转换为数据模型
class Network {
  Network._();

  ///账号密码登录
  static Future<UserLoginEntity?> accountLogin(String account, String password) async {
    final params = <String, dynamic>{};

    ///18848431874 12345678
    params['account'] = account;
    params['password'] = password;
    params['sid'] = AppData.sid;
    params['registrationId'] = AppData.jPushRegistrationID;
    params['lastLoginPlatform'] = GetPlatform.isIOS ? 2 : 1;

    final response = await BaseNetwork.post(ApiType.userCenter, Api.accountLogin, params: params);
    final result = BaseEntity.fromJson(response, fromJsonT: (json) => UserLoginEntity.fromJson(json));
    AppData.tokenName = result.data?.tokenName;
    AppData.tokenValue = result.data?.tokenValue;
    logger.i('token ---${AppData.tokenValue}');
    AppData.cid = result.data?.cid;
    AppData.sid = result.data?.sid;
    return result.data;
  }

  ///获取短信验证码
  ///smsType 短信类型 默认 default
  /// bindingAccount 账号绑定
  /// 注册 regist
  /// 找回密码 resetpwd
  /// 渠道商售后订单 afterSale
  /// 定制 customize
  /// 余额不足 money
  /// 渠道异常订单 failorder
  /// 定制 customize
  /// 售后订单 returnorder
  /// 店铺入住 storecheck
  /// 提现 withdraw
  /// 存储订单 store_order
  /// 引导订单 guide_order
  /// 修改手机号 edit_mobile
  /// 新增银行卡 add_bank 修改密码
  /// edit_password
  /// 修改支付密码 edit_pay_password
  static Future<bool> getMsgCode(String mobile, String smsType) async {
    final params = <String, String>{};
    params['mobile'] = mobile;
    params['sid'] = GlobalData.sid;
    params['smsType'] = smsType;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.msgCode, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///校验短信验证码
  static Future<bool> checkMsgCode(String mobile, String code, String smsType) async {
    final params = <String, String>{};
    params['mobile'] = mobile;
    params['code'] = code;
    params['sid'] = AppData.sid!;
    params['smsType'] = smsType;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.checkMsgCode, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///完成注册
  static Future completeRegister(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.completeRegister, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///手机验证码登录
  static Future phoneLogin(String mobile, String code, String smsType) async {
    final params = <String, dynamic>{};
    params['mobile'] = mobile;
    params['code'] = code;
    params['sid'] = AppData.sid!;
    params['smsType'] = smsType;
    params['registrationId'] = AppData.jPushRegistrationID;
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;
    params['lastLoginPlatform'] = GetPlatform.isIOS ? 2 : 1;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.phoneLogin, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///忘记密码
  static Future forgetPassword(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.forgetPassword, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///我的优惠券
  static Future getMyCouponList(int status, int type, int pageNum, int pageSize) async {
    final params = <String, String>{};
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    params['status'] = status.toString();
    params['type'] = type.toString();
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.myCouponList}/${type}/${status}", params: params);
    print(response);
    final result = BaseEntity.fromJson(
      response,
      // fromJsonT: (json) => CouponListEntity.fromJson(json),
    );
    return result.data;
  }

  ///已领取的优惠券类型及数量
  static Future getCouponReceiveNum() async {
    final response = await BaseNetwork.get(ApiType.userCenter, params: {'type': 0}, Api.couponReceiveNum);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取可领取的优惠券列表
  static Future<CouponListEntity?> getCanReceiveCouponList(int pageNum, int pageSize) async {
    final params = <String, String>{};
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    final response = await BaseNetwork.get(ApiType.userCenter, Api.canReceiveCouponList, params: params);
    print(response);
    final result = BaseEntity.fromJson(
      response,
      fromJsonT: (json) => CouponListEntity.fromJson(json),
    );
    return result.data;
  }

  ///领取优惠券
  static Future<bool> receiveCoupon(String couponId) async {
    final params = <String, String>{};
    params['couponId'] = couponId;
    params['sid'] = AppData.sid!;
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.receiveCoupon}/${couponId}", params: params);
    // print(response);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///兑换优惠券
  static Future<bool> exchangeCoupon(String code) async {
    final params = <String, String>{};
    params['code'] = code;
    final response = await BaseNetwork.get(ApiType.userCenter, Api.exchangeCoupon, params: params);
    // print(response);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的红包
  static Future getMyRedPacketList(int status, int pageNum, int pageSize) async {
    final params = <String, String>{};
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    final response = await BaseNetwork.get(ApiType.userCenter, '${Api.queryMyRedPacketList}/${status}', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///兑换红包
  static Future<bool> exchangeRedpack(String code) async {
    final params = <String, String>{};
    params['code'] = code;
    final response = await BaseNetwork.get(ApiType.userCenter, Api.exchangeRedpack, params: params);
    // print(response);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的门店券
  static Future getMyStoreVoucher() async {
    final params = <String, String>{};
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.getMyStoreVoucher, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///兑换门店券
  static Future storeExchange(String code) async {
    final params = <String, String>{};
    params['code'] = code;
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.storeExchange, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///红包退款
  static Future<bool> redpackRefund(String id) async {
    final params = <String, String>{};
    params['id'] = id;
    final response = await BaseNetwork.put(ApiType.userCenter, '${Api.redpackRefund}/${id}', params: params);
    print(response);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取可提现金额
  static Future getWithdraw() async {
    final params = <String, String>{};
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getWithdraw, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取提现配置
  static Future getConfig() async {
    final params = <String, String>{};
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getConfig, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取提现记录
  static Future getwithdrawList(int pageNum, int pageSize) async {
    final params = <String, int>{};
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    final response = await BaseNetwork.get(ApiType.userCenter, Api.withdrawList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取余额明细
  static Future getWithdrawLog(dynamic type, int pageNum, int pageSize) async {
    final params = <String, dynamic>{};
    params['type'] = type;
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    final response = await BaseNetwork.get(ApiType.userCenter, Api.withdrawLog, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///发起提现
  static Future applyWithdraw(double amount, String bankId) async {
    final params = <String, dynamic>{};
    params['amount'] = amount;
    params['bankId'] = bankId;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.applyWithdraw, params: params);
    print("这里$response");
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的地址列表
  static Future<List<AddressListEntity?>?> getAddress() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.addressList);
    final result = BaseEntity.fromJson(response, fromJsonT: (json) => AddressListEntity.fromJson(json));
    return result.listData;
  }

  ///获取省市区
  static Future getProvinceCityArea() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.provinceCityArea);
    if (response['code'] == 200) {
      return response['data'];
    }
  }

  ///新增收货地址
  static Future<bool> addAddress(int province, int city, int district, int isDefault, String name, String address, String mobile) async {
    final params = <String, dynamic>{};
    params['receiveName'] = name;
    params['receivePhone'] = mobile;
    params['receiveAddress'] = address;
    params['province'] = province;
    params['city'] = city;
    params['district'] = district;
    params['isDefault'] = isDefault;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.addAddress, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///修改收货地址
  static Future<bool> updateAddress(String id, int province, int city, int district, int isDefault, String name, String address, String mobile) async {
    final params = <String, dynamic>{};
    params['id'] = id;
    params['receiveName'] = name;
    params['receivePhone'] = mobile;
    params['receiveAddress'] = address;
    params['province'] = province;
    params['city'] = city;
    params['district'] = district;
    params['isDefault'] = isDefault;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.updateAddress, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除地址
  static Future<bool> deleteAddress(String id) async {
    final params = <String, dynamic>{};
    final response = await BaseNetwork.post(ApiType.userCenter, '${Api.deleteAddress}/$id', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取银行卡列表
  static Future<List<BankCardItemEntity?>?> getBankCardList() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.bankCardList);
    logger.d("原始response: ${response}");

    // 解析成扁平的List<BankCardItemEntity>
    final result = BaseEntity.fromJson(response, fromJsonT: (json) => BankCardItemEntity.fromJson(json));

    logger.d("解析后的银行卡列表: ${result.listData}");
    // 返回银行卡列表
    return result.listData;
  }

  ///获取我的银行卡列表（json格式）
  static Future getMyBankCardList() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.bankCardList);
    // print(response);
    final result = BaseEntity.fromJson(
      response,
    );

    logger.d("这里是银行卡返回值:${result}");
    return result.data;
  }

  ///获取图形验证码
  static Future<Map<String, dynamic>?> getImageCode() async {
    final params = <String, String>{};
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getImageCode, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取开户行列表
  static Future<List<KhhListEntity?>?> getKhhList() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.khhList);
    final result = BaseEntity.fromJson(response, fromJsonT: (json) => KhhListEntity.fromJson(json));
    return result.listData;
  }

  ///新增银行卡
  static Future<bool> addBankCard(String bankCard, int bankId, String bankName, String graphicsVerifyCode, String graphicsVerifyKey, String idcard, String mobile, String mobileVerifyCode, String trueName) async {
    final params = <String, dynamic>{};
    params['bankCard'] = bankCard;
    params['bankId'] = bankId;
    params['bankName'] = bankName;
    params['graphicsVerifyCode'] = graphicsVerifyCode;
    params['graphicsVerifyKey'] = graphicsVerifyKey;
    params['idcard'] = idcard;
    params['mobile'] = mobile;
    params['mobileVerifyCode'] = mobileVerifyCode;
    params['trueName'] = trueName;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.addBankCard, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取首页装修配置
  static Future getIndexDecorationConfig() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.indexDecoration, params: params);
    final result = BaseEntity.fromJson(
      response,
    );
    return result.data;
  }

  ///获取抽奖配置
  static Future<LotteryBean?> getRaffle() async {
    Map<String, dynamic> params = {};
    // params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.getRaffle}?sid=${AppData.sid}', params: params);
    final result = BaseEntity.fromJson(
      response,
      fromJsonT: (json) => LotteryBean.fromJson(json),
    );
    return result.data;
  }

  ///获取抽奖结果
  static Future<LotterResultBean?> getRaffleResult() async {
    Map<String, dynamic> params = {};
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.getRaffleResult}', params: params);
    final result = BaseEntity.fromJson(
      response,
      fromJsonT: (json) => LotterResultBean.fromJson(json),
    );
    return result.data;
  }

  ///获取抽奖结果列表
  static Future<LotteryListBean?> getRaffleResultList() async {
    Map<String, dynamic> params = {};
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.getRaffleResultList}?sid=${AppData.sid}', params: params);
    final result = BaseEntity.fromJson(
      response,
      fromJsonT: (json) => LotteryListBean.fromJson(json),
    );
    // final result = BaseEntity<LotteryListBean>.fromJson(response);
    return result.data;
  }

  ///请求签到
  static Future getSignInResult() async {
    Map<String, dynamic> params = {};
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.getSignInList}?sid=${AppData.sid}', params: params);
    // final result = BaseEntity.fromJson(
    //   response,
    //   fromJsonT: (json) => SignInPrizeBean.fromJson(json),
    // );
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取签到记录
  static Future<SignInRecoredBean?> getSignInResultRecord() async {
    Map<String, dynamic> params = {};
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.getSignInRecord}?sid=${AppData.sid}', params: params);
    final result = BaseEntity.fromJson(
      response,
      fromJsonT: (json) => SignInRecoredBean.fromJson(json),
    );
    return result.data;
  }

  ///获取会员中心的装修
  static Future getMemberPage() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.getmemberpage, params: params);
    final result = BaseEntity.fromJson(
      response,
    );
    return result.data;
  }

  ///添加银行卡 - 获取短信验证码
  static Future<bool> getBankPhoneCode(String mobile) async {
    final params = <String, dynamic>{};
    // params['mobile'] = mobile;
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.getBankPhoneCode}?mobile=${mobile}", params: params);
    print(response);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除银行卡
  static Future<bool> deleteBankcard(String id) async {
    final params = <String, dynamic>{};
    final response = await BaseNetwork.post(ApiType.userCenter, '${Api.deleteBankcard}/$id', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取商品分类
  static Future getGoodsClassify() async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, '${Api.goodsClassify}/${AppData.sid}');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取品牌列表
  static Future getBrandList() async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, '${Api.brandList}/${AppData.sid}');
    final result = BaseEntity.fromJson(
      response,
      // fromJsonT: (json) => ClassifyItemEntity.fromJson(json),
    );
    return result.data;
  }

  ///获取我的订单列表
  static Future getMyOrderList(int type, int pageNum, int pageSize, {String? keyword = '', int? orderType}) async {
    final params = <String, dynamic>{};
    if (orderType != null) {
      params['orderType'] = orderType;
    }
    params['keyWord'] = keyword.toString();
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    params['sid'] = AppData.sid;

    final response = await BaseNetwork.get(ApiType.orderCenter, "${Api.myOrderList}/${type}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取评论数量
  static Future getCommentNum() async {
    final params = <String, dynamic>{};
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.getCommentNum, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的拼团列表
  static Future getGroupList(dynamic type, int pageNum, int pageSize) async {
    final params = <String, dynamic>{};
    params['bookStatus'] = type;
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.groupList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的拼团详情
  static Future getGroupDetail(String orderId) async {
    final params = <String, dynamic>{};
    params['orderId'] = orderId;
    final response = await BaseNetwork.get(ApiType.orderCenter, "${Api.groupDetail}/${orderId}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 拼团 参团
  static Future getGroupJoinDetail(String bookId) async {
    final params = <String, dynamic>{};
    params['bookId'] = bookId;
    final response = await BaseNetwork.get(ApiType.orderCenter, "${Api.groupJoinDetail}/${bookId}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///发起砍价
  static Future creatHaggle(String activityId, String goodsId) async {
    final params = <String, dynamic>{};
    params['activityId'] = activityId;
    params['goodsId'] = goodsId;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.creatHaggle, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///砍价列表
  static Future getHaggleList(dynamic type, int pageNum, int pageSize) async {
    final params = <String, dynamic>{};
    params['haggleStatus'] = type;
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.haggleList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///砍价详情
  static Future getHaggleDetail(String haggleId) async {
    final params = <String, dynamic>{};
    params['haggleId'] = haggleId;
    final response = await BaseNetwork.get(ApiType.orderCenter, "${Api.haggleDetail}/${haggleId}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取预付卡列表
  static Future getPrepaymentCardList(int pageNum, int pageSize) async {
    final params = <String, dynamic>{};
    params['pageNum'] = pageNum.toString();
    params['pageSize'] = pageSize.toString();
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getPrepaymentCardList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///绑定预付卡
  static Future addPrepaymentCard(String cardNum, String password) async {
    final params = <String, String>{};
    params['cardNum'] = cardNum;
    params['password'] = password;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.addPrepaymentCard, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除预付卡
  static Future delPrepaymentCard(int id) async {
    final response = await BaseNetwork.delete(ApiType.userCenter, "${Api.delPrepaymentCard}/$id");
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///确认收货
  static Future receive(String orderId) async {
    final params = <String, String>{};
    params['sid'] = AppData.sid.toString();
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;

    final response = await BaseNetwork.put(ApiType.orderCenter, '${Api.receive}/$orderId', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///售后确认收货
  static Future orderReturnReceive(String orderId) async {
    final params = <String, String>{};
    params['sid'] = AppData.sid.toString();
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;

    final response = await BaseNetwork.put(ApiType.orderCenter, '${Api.orderReturnReceive}/$orderId', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///保价顶部统计查询
  static Future baojiadingbuchaxun() async {
    var params = {
      'client': GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid,
      'sid': AppData.sid,
    };

    final response = await BaseNetwork.get(ApiType.orderCenter, Api.baojiadingbuchaxun, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///保价列表
  static Future baojialiebiao(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.baojialiebiao, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///预售订单
  static Future saleBaojialiebiao(Map<String, dynamic> params) async {
    params['orderType'] = '5';
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.baojialiebiao, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///保价申请记录
  static Future baojiashenqingjilu(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.baojiashenqingjilu, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///申请保价
  static Future shenqingbaojia(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.shenqingbaojia, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///取消订单
  static Future cancelOrder(String orderId) async {
    final response = await BaseNetwork.delete(ApiType.orderCenter, '${Api.cancelOrder}/$orderId');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除订单
  static Future deleteOrder(String orderId) async {
    final response = await BaseNetwork.delete(ApiType.orderCenter, '${Api.deleteOrder}/$orderId');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取商品分类详情
  static Future getGoodsClassifyDetail(String id) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, '${Api.goodsClassifyDetail}/$id');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取积分明细
  static Future getPointLog(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.pointLog, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取积分明细
  static Future getVipcardList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.vipcardList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取vip信息
  static Future getVipInfo(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.vipInfo, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取用户可购买的权益卡列表
  static Future getVipCanBuyCardList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.vipCanBuyCardList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取个用户已有的权益卡
  static Future getVipHaveCardList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.vipHaveCardList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 直接领取卡
  static Future getVipReceiveCard(String cardId) async {
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.vipReceiveCard}/$cardId");
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 购买卡
  static Future vipBuyCardPlaceCard(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.vipBuyCardPlaceCardOrder, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取营销活动时间列表
  ///type 活动类型 1-整单促销 2-商品促销 3-秒杀 4-拼团 5-特价直降 6-预售 7-砍价 8-支付优惠 9-新人好礼
  /// 10-拉新配置 11-优惠券 12-抽奖 13-返券 14-分享赚 15-红包 16-运费券 17-门店券 18-加价购 19-顺手买一件 20-签到
  ///activityType 活动类型 1-特价 2-天天补贴 3-保税好价 4-新品榜单 5-9.9专区
  static Future getActivityTimes(String type, {String? activityType}) async {
    final Map<String, dynamic> params = {};
    final String sid = AppData.sid.toString();
    params['type'] = type;
    if (activityType != null) {
      params['activityType'] = activityType;
    }
    params['sid'] = sid;
    final response = await BaseNetwork.get(ApiType.marketingCenter, "${Api.todayActivityTimes}/${type}?sid=${sid}", params: params);
    logger.i('获取营销活动时间列表$response');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 新品榜单-导航条
  static Future getActivityNewProductNavigation() async {
    final String sid = AppData.sid.toString();
    final response = await BaseNetwork.get(ApiType.marketingCenter, "${Api.frontendNavigation}/?sid=$sid");
    logger.i('新品榜单-导航条$response');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取拼团商品列表
  static Future getBookGoodsList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.bookGoodsList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取砍价的商品
  static Future getBargaining(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.bragainingGoodsList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取秒杀列表
  static Future getKillSale(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, "${Api.killSale}/${params['marketingId']}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///查看可手动领取的红包列表
  static Future queryCanClaimedRedPacketList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.queryCanClaimedRedPacketList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取特价商品列表
  static Future getSpecialGoodsList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.specialGoodsList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取预售商品列表
  static Future getPreSalesGoodsListMap(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.marketingCenter, Api.preSalesGoodsList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///收藏商品
  static Future<bool> collect(String goodsId) async {
    final Map<String, dynamic> params = {};
    params['goodsId'] = goodsId;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.collect, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///批量收藏商品
  static Future<bool> collectMut(List<String> goodsIds) async {
    final Map<String, dynamic> params = {};
    params['goodsIds'] = goodsIds;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.collectMut, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取收藏列表
  static Future getCollectList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.getCollectList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除收藏
  static Future deleteCollect(String goodsId) async {
    final Map<String, String> params = {};
    params['goodsId'] = goodsId;
    final response = await BaseNetwork.delete(ApiType.goodsCenter, "${Api.deleteCollect}/${goodsId}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///批量删除收藏
  static Future deleteCollectMut(List goodsId) async {
    final Map<String, dynamic> params = {};
    params['goodsIds'] = goodsId;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.deleteCollectMut, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取商品列表
  static Future getGoodsList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.goodsList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取商品详情 type 0-普通商品 1-特价商品 2-拼团商品 3-秒杀商品 4-砍价商品5-预售商品
  static Future getGoodsDetail(String id, Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, '${Api.goodsDetail}/$id', params: params);

    final result = BaseEntity.fromJson(response);
    print('xxxxx 看看获取商品详情 ${result.data}');
    return result.data;
  }

  ///获取订单详情
  static Future getOrderDetail(String id) async {
    final response = await BaseNetwork.get(ApiType.orderCenter, '${Api.orderDetail}/$id');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///评价
  static Future<bool> comment(String channelID, String orderID, String paySn, String sn, double productConformity, double storeServices, double expressPackaging, double expressDeliveryStars, double courierStars, double channelStars, String commentText, List<CommentFileEntity> commentFile) async {
    final params = <String, dynamic>{};
    params['channelID'] = channelID;
    params['orderID'] = orderID;
    params['paySn'] = paySn;
    params['sn'] = sn;
    params['productConformity'] = productConformity;
    params['storeServices'] = storeServices;
    params['expressPackaging'] = expressPackaging;
    params['expressDeliveryStars'] = expressDeliveryStars;
    params['courierStars'] = courierStars;
    params['channelStars'] = channelStars;
    params['commentText'] = commentText;
    params['commentFile'] = commentFile;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.comment, params: params);

    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取购物车列表
  static Future getCarList() async {
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.carList);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///加入购物车
  static Future<bool> addCar(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.addCar, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取oss配置
  static Future getOssConfig() async {
    final params = <String, dynamic>{};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.partnerCenter, Api.ossConfig, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///准备下单
  static Future prePlaceOrder(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.prePlaceOrder, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///下单
  static Future placeOrder(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.placeOrder, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///实名认证提交
  static Future userAuth(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.userAuth, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取实名认证
  static Future getUserAuth() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getUserAuth);

    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取用户信息
  static Future getUserInfo() async {
    final params = {'sid': AppData.sid};
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getUserInfo, params: params);

    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取”我的”页面的数据
  static Future getMine() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getMine);

    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///编辑用户的昵称和头像
  static Future updateUserInfo(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.updateUserInfo, params: params);

    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  //修改手机号 - 获取旧验证码
  static Future<bool> editMobileVerifyCode() async {
    final params = <String, dynamic>{};
    final response = await BaseNetwork.get(ApiType.userCenter, Api.editMobileVerifyCode, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  //修改手机号 - 获取新手机号的验证码
  static Future<bool> editNewMobileVerifyCode(String mobile) async {
    final params = <String, dynamic>{};
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.editNewMobileVerifyCode}?mobile=${mobile}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  //修改手机号 - 验证旧手机号
  static Future<bool> checkVerifyCode(String mobile, String code) async {
    final params = <String, dynamic>{};
    params['code'] = code;
    params['mobile'] = mobile;
    params['sid'] = AppData.sid;
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;
    // params['loginCode'] =code;

    final response = await BaseNetwork.post(ApiType.userCenter, Api.checkVerifyCode, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  //修改手机号 - 提交新手机号
  static Future<bool> editMobile(String mobile, String code) async {
    final params = <String, dynamic>{};
    params['code'] = code;
    params['mobile'] = mobile;
    params['sid'] = AppData.sid;

    final response = await BaseNetwork.post(ApiType.userCenter, Api.editMobile, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  // 修改密码 0 登录密码 1、支付密码
  static Future<bool> editPassword(String confirmPassword, String newPassword, int type) async {
    final params = <String, dynamic>{};
    params['confirmPassword'] = confirmPassword;
    params['newPassword'] = newPassword;
    params['type'] = type;

    final response = await BaseNetwork.post(ApiType.userCenter, Api.editPassword, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取商品评价列表
  static Future getGoodsCommentList(String id, Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, "${Api.goodsCommentList}/$id", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取我的足迹
  static Future getHistory() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.getHistory);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除足迹
  static Future deleteHistory(List ids) async {
    Map<String, List> params = {"id": ids};
    final response = await BaseNetwork.post(ApiType.userCenter, Api.deleteHistory, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///批量选中和反选
  static Future<bool> chooseMulti(List<String> ids, int isSelect) async {
    Map<String, dynamic> params = {};
    params['ids'] = ids;
    params['isSelect'] = isSelect;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.toggleSelectAll, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取购物车商品数量
  static Future<int> getCarGoodsNum() async {
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.carGoodsNum);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///删除购物车商品
  static Future<bool> deleteCarGoods(String id) async {
    final response = await BaseNetwork.delete(ApiType.goodsCenter, '${Api.deleteCarGoods}/$id');
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///批量删除购物车商品
  static Future<bool> batchDeleteCarGoods(List<String> ids) async {
    Map<String, dynamic> params = {};
    params['ids'] = ids;
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.batchDeleteCarGoods, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取开屏广告
  static Future getSplashAd() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.splashAd, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取店铺配置和协议
  static Future getStoreConfig() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.getStoreConfig, params: params);
    final result = BaseEntity.fromJson(response);
    // print(result.data);
    return result.data;
  }

  ///获取退款原因
  static Future getRefundReason() async {
    final response = await BaseNetwork.get(ApiType.orderCenter, Api.getRefundReason);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 准备售后
  static Future getRefundPrepare(params) async {
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.applyReturnPrepare, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///申请售后
  static Future applyReturn(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.applyReturn, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///个性化配置
  static Future modifyRecommendConfig(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.modifyRecommendConfig, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  static Future afterSalesDetail(String id) async {
    final params = <String, dynamic>{};
    params['id'] = id;
    final response = await BaseNetwork.get(ApiType.orderCenter, "${Api.afterSalesDetail}/${id}", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取品牌详情
  static Future getBrandDetail(String brandId) async {
    Map<String, dynamic> params = {};
    params['brandId'] = brandId;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.brandDetail, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///根据分组id获取商品
  static Future getGoodsById(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.goodsById, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///支付订单
  static Future payOrder(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.partnerCenter, Api.payOrder, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///权益卡购买支付
  static Future payCard(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.partnerCenter, Api.payCard, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取支付方式
  static Future getPayMethod() async {
    Map<String, dynamic> params = {};
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.payMethod, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取个性推荐商品
  static Future getRecommendList(int pageNum, int pageSize, {String location = '', String goodsId = ''}) async {
    Map<String, dynamic> params = {};
    params['location'] = location;
    params['goodsId'] = goodsId;
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.recommendList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取最近一场营销活动商品 3秒杀 4拼团 5特价
  static Future getRecentlyMarketingGoods(int type, int pageNum, int pageSize) async {
    Map<String, dynamic> params = {};
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.recentlyMarketingGoodsList}/$type', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///手动查询营销活动商品
  static Future manualQueryMarketingGoods(String type, int pageNum, int pageSize, String marketingId) async {
    Map<String, dynamic> params = {};
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.marketingCenter, '${Api.manualMarketingGoodsList}/$marketingId/$type', params: params);
    final result = BaseEntity.fromJson(response);

    logger.i('手动查询营销活动商品 $result');

    return result.data;
  }

  ///获取微页面配置
  static Future getMicroConfig(String id) async {
    final response = await BaseNetwork.get(
      ApiType.shopCenter,
      '${Api.microConfig}/$id',
    );
    final result = BaseEntity.fromJson(response);
    print('result ======== ${result.data}');
    return result.data;
  }

  ///微信授权登录
  static Future wechatAuthLogin(String loginCode) async {
    Map<String, dynamic> params = {};
    params['loginCode'] = loginCode;
    params['sid'] = AppData.sid;
    params['registrationId'] = AppData.jPushRegistrationID;
    params['client'] = GetPlatform.isIOS ? AppConfig.clientIos : AppConfig.clientAndroid;
    params['lastLoginPlatform'] = GetPlatform.isIOS ? 2 : 1;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.wechatAuthLogin, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取引导页广告
  static Future getGuideAd() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.guideAd, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取主页弹窗广告
  static Future getIndexAd() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.indexPopupAd, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取微页面弹窗广告
  static Future getMicroAd() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.microPopupAd, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///修改购物车商品
  static Future modifyCarGoods(Map<String, dynamic> params, String carId) async {
    final response = await BaseNetwork.put(ApiType.goodsCenter, '${Api.modifyCar}/$carId', params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///搜索建议
  static Future searchSuggest(Map<String, dynamic> params) async {
    final response = await BaseNetwork.get(ApiType.goodsCenter, Api.searchSuggest, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取搜素热词
  static Future getHotWord() async {
    Map<String, dynamic> params = {};
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.shopCenter, Api.hotWord, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///绑定账号
  static Future bindAccount(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.bindAccount, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///商品详情活动信息
  static Future goodsDetailActivity(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.goodsCenter, Api.detailActivity, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///领取红包
  static Future<bool> receiveRedPack(String redPacketId) async {
    final params = <String, String>{};
    params['redPacketId'] = redPacketId;
    params['sid'] = AppData.sid!;
    final response = await BaseNetwork.get(ApiType.userCenter, "${Api.receiveRedPack}/$redPacketId", params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取可用积分
  static Future getCanUsePoints(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.canUsePoints, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取可用预付卡
  static Future getCanUsePayCard(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.canUsePayCard, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///验证支付密码
  static Future validatePayPassword(String password) async {
    final params = <String, String>{};
    params['password'] = password;
    final response = await BaseNetwork.post(ApiType.userCenter, Api.checkPayPassword, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///上传物流
  static Future shipping(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.shipping, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///是否有支付密码
  static Future<bool> hasPayPassword() async {
    final response = await BaseNetwork.get(ApiType.userCenter, Api.hasPayPassword);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///获取app信息
  static Future<PackageInfo> getAppInfo() async {
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    return packageInfo;
  }

  ///
  static Future getSpecialTopic(int pageNum, int pageSize, String goodId) async {
    Map<String, dynamic> params = {};
    params['pageNum'] = pageNum;
    params['pageSize'] = pageSize;
    params['sid'] = AppData.sid;
    final response = await BaseNetwork.get(ApiType.goodsCenter, '${Api.specialTopic}/$goodId', params: params);
    final result = BaseEntity.fromJson(response);

    logger.i('专题结果 $result');

    return result.data;
  }

  static Future getPrepareFinalPay(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.prepareFinalPay, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 定金预售付尾款提交
  static Future getPlaceOrderFinalPay(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.orderCenter, Api.placeOrderFinalPay, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 获取端渠道配置信息
  static Future getDefaultInfo() async {
    final String sid = AppData.sid.toString();
    final response = await BaseNetwork.get(ApiType.shopCenter, "${Api.getDefaultInfo}/?sid=$sid");
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///自动获取红包-自动发放
  static Future automaticGainRedPacketList(Map<String, dynamic> params) async {
    final String sid = AppData.sid.toString();
    params['sid'] = sid;
    final response = await BaseNetwork.post(ApiType.marketingCenter, Api.automaticGainRedPacketList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  ///自动获取优惠券-自动发放
  static Future automaticGainCouponList(Map<String, dynamic> params) async {
    final String sid = AppData.sid.toString();
    params['sid'] = sid;
    final response = await BaseNetwork.post(ApiType.marketingCenter, Api.automaticGainCouponList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  static Future getBdOrderGetUrl() async {
    final response = await BaseNetwork.get(ApiType.partnerCenter, Api.bdorderGeturl);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }

  /// 获取通知列表
  static Future getNoticeList(Map<String, dynamic> params) async {
    final response = await BaseNetwork.post(ApiType.userCenter, Api.getNoticeList, params: params);
    final result = BaseEntity.fromJson(response);
    return result.data;
  }
}
